<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改题目')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-problem-edit" th:object="${problem}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">试题类型：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control m-b" th:with="type=${@dict.getType('school_problem_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">试题内容：</label>
                <div class="col-sm-8">
                    <input type="hidden" class="form-control" th:field="*{content}">
                    <div class="summernote" id="content"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">普通文本还是markdown：</label>
                <div class="col-sm-8">
                    <select name="contentType" class="form-control m-b" th:with="type=${@dict.getType('school_problem_content_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{contentType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">关联章节编号：</label>
                <div class="col-sm-8">
                    <input name="cId" th:field="*{cId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">关联知识点编号：</label>
                <div class="col-sm-8">
                    <input name="kId" th:field="*{kId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数1：</label>
                <div class="col-sm-8">
                    <input name="score1" th:field="*{score1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数2：</label>
                <div class="col-sm-8">
                    <input name="score2" th:field="*{score2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数3：</label>
                <div class="col-sm-8">
                    <input name="score3" th:field="*{score3}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数4：</label>
                <div class="col-sm-8">
                    <input name="score4" th:field="*{score4}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数5：</label>
                <div class="col-sm-8">
                    <input name="score5" th:field="*{score5}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数6：</label>
                <div class="col-sm-8">
                    <input name="score6" th:field="*{score6}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数7：</label>
                <div class="col-sm-8">
                    <input name="score7" th:field="*{score7}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数8：</label>
                <div class="col-sm-8">
                    <input name="score8" th:field="*{score8}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数9：</label>
                <div class="col-sm-8">
                    <input name="score9" th:field="*{score9}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分数10：</label>
                <div class="col-sm-8">
                    <input name="score10" th:field="*{score10}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项1A：</label>
                <div class="col-sm-8">
                    <input name="option1" th:field="*{option1}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项2B：</label>
                <div class="col-sm-8">
                    <input name="option2" th:field="*{option2}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项3C：</label>
                <div class="col-sm-8">
                    <input name="option3" th:field="*{option3}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项4D：</label>
                <div class="col-sm-8">
                    <input name="option4" th:field="*{option4}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项5E：</label>
                <div class="col-sm-8">
                    <input name="option5" th:field="*{option5}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项6F：</label>
                <div class="col-sm-8">
                    <input name="option6" th:field="*{option6}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项7G：</label>
                <div class="col-sm-8">
                    <input name="option7" th:field="*{option7}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项8H：</label>
                <div class="col-sm-8">
                    <input name="option8" th:field="*{option8}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项9I：</label>
                <div class="col-sm-8">
                    <input name="option9" th:field="*{option9}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">选项10J：</label>
                <div class="col-sm-8">
                    <input name="option10" th:field="*{option10}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案1：</label>
                <div class="col-sm-8">
                    <textarea name="answer1" class="form-control">[[*{answer1}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案2：</label>
                <div class="col-sm-8">
                    <textarea name="answer2" class="form-control">[[*{answer2}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案3：</label>
                <div class="col-sm-8">
                    <textarea name="answer3" class="form-control">[[*{answer3}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案4：</label>
                <div class="col-sm-8">
                    <textarea name="answer4" class="form-control">[[*{answer4}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案5：</label>
                <div class="col-sm-8">
                    <textarea name="answer5" class="form-control">[[*{answer5}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案6：</label>
                <div class="col-sm-8">
                    <textarea name="answer6" class="form-control">[[*{answer6}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案7：</label>
                <div class="col-sm-8">
                    <textarea name="answer7" class="form-control">[[*{answer7}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案8：</label>
                <div class="col-sm-8">
                    <textarea name="answer8" class="form-control">[[*{answer8}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案9：</label>
                <div class="col-sm-8">
                    <textarea name="answer9" class="form-control">[[*{answer9}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">答案10：</label>
                <div class="col-sm-8">
                    <textarea name="answer10" class="form-control">[[*{answer10}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">上传地址1：</label>
                <div class="col-sm-8">
                    <textarea name="upload1" class="form-control">[[*{upload1}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">上传地址2：</label>
                <div class="col-sm-8">
                    <textarea name="upload2" class="form-control">[[*{upload2}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">上传地址3：</label>
                <div class="col-sm-8">
                    <textarea name="upload3" class="form-control">[[*{upload3}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "school/problem";
        $("#form-problem-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-problem-edit').serialize());
            }
        }

        $(function() {
            $('.summernote').each(function(i) {
                $('#' + this.id).summernote({
                    lang: 'zh-CN',
                    dialogsInBody: true,
                    callbacks: {
                        onChange: function(contents, $edittable) {
                            $("input[name='" + this.id + "']").val(contents);
                        },
                        onImageUpload: function(files) {
                            var obj = this;
                            var data = new FormData();
                            data.append("file", files[0]);
                            $.ajax({
                                type: "post",
                                url: ctx + "common/upload",
                                data: data,
                                cache: false,
                                contentType: false,
                                processData: false,
                                dataType: 'json',
                                success: function(result) {
                                    if (result.code == web_status.SUCCESS) {
                                        $('#' + obj.id).summernote('insertImage', result.url);
                                    } else {
                                        $.modal.alertError(result.msg);
                                    }
                                },
                                error: function(error) {
                                    $.modal.alertWarning("图片上传失败。");
                                }
                            });
                        }
                    }
                });
                var content = $("input[name='" + this.id + "']").val();
                $('#' + this.id).summernote('code', content);
            })
        });
    </script>
</body>
</html>